package ctrlayer;
import modellayer.*;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
 * The test class OrdreCtrTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class OrdreCtrTest
{
    private static int counterO = 1;
    private ctrlayer.OrdreCtr ordreCtr1 = new ctrlayer.OrdreCtr();
    private ctrlayer.VareCtr vareCtr1 = new ctrlayer.VareCtr();
    private ctrlayer.PersonCtr personCtr1 = new ctrlayer.PersonCtr();
    /**
     * Default constructor for test class OrdreCtrTest
     */
    public OrdreCtrTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        vareCtr1.createVare("Hammer", "It's hammertime", 24.95, 123, 100, 10, 1000);
        personCtr1.createKunde("Bob", "123", "123", "Aalborg", "123", "Hej@hej.dk");
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {

    }

    @Test
    public void createOrdre()
    {
        assertEquals(true, ordreCtr1.createOrdre("123", false, true, "11-11-2011", "Sendt", 0));
        counterO++;
    }

    @Test
    public void removeOrdre()
    {
        ordreCtr1.createOrdre("123", false, true, "4", "Hej", 0);
        assertEquals(true, ordreCtr1.removeOrdre("123", counterO));
        counterO++;
    }

    @Test
    public void removeOrdreDerIkkeErDer()
    {
        assertEquals(false, ordreCtr1.removeOrdre("123", Integer.MAX_VALUE));
    }

    @Test
    public void ad()
    {
        ordreCtr1.createOrdre("123", false, true, "Bæver", "Bæver", 0);
        Vare v = vareCtr1.findVareMedStregkode(123);
        assertEquals(true, ordreCtr1.addVareTilOrdre(counterO, v.getVareID(), 1));
        counterO++;
    } 

    @Test
    public void sletVareFraOrdre()
    {
        Vare v = vareCtr1.findVareMedStregkode(123);
        ordreCtr1.createOrdre("123", false, true, "Bæver", "Bæver", 0);
        ordreCtr1.addVareTilOrdre(counterO, v.getVareID(), 1);
        Vare vNy = ordreCtr1.findVarePåListStregkode(counterO, 123);
        assertEquals(true, ordreCtr1.deleteVareFraListe(counterO, vNy.getVareID()));
        counterO++;
    }
}

